The present invention relates to databases, and more specifically, to a computer-implemented method, a system and a computer program product for debugging a program including a structured query language statement.
A program written in an object oriented programming language such as Java language or a procedural programming language such as C language can be debugged step by step. However, since structured query language (SQL) is known as a descriptive programming language, there are typically a large number of alternative ways to execute a given query, with widely varying performance. When a SQL query (a kind of SQL statement) is submitted to the database, an optimizer evaluates some of the different possible plans for executing the SQL query and returns what it considers the best option. That is, the database management system (DBMS) will choose an execution plan with the lowest cost depending on calculation of the optimizer from among a plurality of possible execution plans.
An execution plan (also referred to as access path) is an ordered set of steps used to access data in a relational database. The access path could be expressed as a tree structure with data processes (such as Index Range Scan, Full Table Scan, and etc.) as its nodes. The data process means a process performed on data, such as sorting, summing, or selecting of data. A leaf node of the tree structure firstly retrieves data from physical data objects and passes the data upwards to its parent node, where the data is further processed before being passed upwards. At the root node, the final result set for the current query is obtained.